home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1989 January & February
/
rerun-1989-01-02.d64
/
chummy checkers
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
4KB
|
172 lines
100 rem---checkers
110 poke52,56:poke56,56:clr
120 gosub1580
130 v=53248:s1=54272:s2=s1+7:sc=1024:tc=646:a=rnd(-ti)
140 fora=1to38:sp$=sp$+chr$(32):next
150 dim bd(63),ch(1),mv$(1),d(1,3),tl(1),pl(1)
160 forz=0to63:bd(z)=sc+168+int(z/8)*80+(zand7)*3:next
170 ch(0)=163:ch(1)=171
180 mv$(0)=left$(sp$,4):mv$(1)="move"
190 d(0,0)=7:d(0,1)=9:d(0,2)=-7:d(0,3)=-9
200 fora=0to3:d(1,a)=-d(0,a):next
210 pokev+39,7:pokev+40,2
220 poke2040,13:poke2041,14
230 fora=s1tos1+24:pokea,0:next
240 pokes1+1,37:pokes1+5,9
250 pokes2+1,5:pokes2+5,8:pokes2+6,240:pokes1+24,15
260 gosub1110
270 p1=0
280 rem---main
290 p2=p1:p1=1-p1:m=0
300 cy=10:cx=2:gosub1490:poketc,1:printmv$(p1)
310 cx=34:gosub1490:poketc,0:printmv$(p2)
320 ifpl(p1)then440
330 rem---computer
340 m1=1:forzz=0to63
350 ifpeek(bd(zz))=ch(p1)thengosub930
360 next:ifm1=1then680
370 ifm1<6thengosub860:goto410
380 gosub820:iftl(p2)=0then680
390 m1=1:zz=qd:gosub930
400 ifm1>=6then380
410 geta$:ifa$=chr$(133)then680
420 goto290
430 rem---player
440 r=p1*7:c=r:pokev+3,0
450 gosub720:ifa$=chr$(133)then680
460 ifpeek(l)<>ch(p1)then450
470 k=-(peek(l+1)=166)
480 pokev+2,peek(v):pokev+16,(peek(v+16)and1)*3:pokev+3,peek(v+1)
490 rf=r:cf=c:lf=l
500 gosub720:ifa$=chr$(133)then680
510 rem---test
520 ifr=rfandc=cfthen500
530 ifpeek(l)<>160then620
540 rm=rf-r:cm=cf-c:ifabs(rm)<>abs(cm)then620
550 ifk=0andsgn(rm)<>sgn(p1-.5)then620
560 ifabs(rm)=1andm=0thengosub860:goto290
570 ifabs(rm)<>2then620
580 rj=rf-rm/2:cj=cf-cm/2
590 lj=bd(rj*8+cj)
600 ifpeek(lj)=ch(p2)then660
610 rem---illegal move
620 ifmthen290
630 pokes2+4,33:fora=1to200:next
640 pokes2+4,32:goto440
650 rem---jump checker
660 gosub820:iftl(p2)then480
670 rem---end of game
680 q$="play again? [y/n] ":se$="yn":gosub1350
690 ifa$="y"then260
700 poke832,0:sys832
710 rem---joystick
720 js=peek(56320)
730 geta$:ifa$=chr$(133)thenreturn
740 r=r+sgn(jsand1)-sgn(jsand2)and7
750 c=c+sgn(jsand4)-sgn(jsand8)and7
760 pokev,88+c*24and255:pokev+16,(peek(v+16)and2)-(c=7)
770 pokev+1,82+r*16
780 pokev+21,3:fora=1to90:next:pokev+21,0
790 ifjsand16then720
800 l=bd(r*8+c):return
810 rem---jump
820 fora=0to2
830 pokelj+a,160:pokelj+40+a,160:next
840 m=m+1:tl(p2)=tl(p2)-1:gosub1290
850 rem---move
860 forz=0to2:pokel+z+s1,p1:pokel+40+z+s1,p1
870 pokel+z,peek(lf+z):pokel+40+z,peek(lf+40+z)
880 pokelf+z,160:pokelf+40+z,160:next
890 ifr=7orr=0thenk=1:pokel+1,166:pokel+41,167
900 pokes1+4,16:pokes1+4,17
910 return
920 rem---find computer move
930 kd=-(peek(bd(zz)+1)=166)
940 fordr=0to1+kd*2:m0=0
950 d=zz+d(p1,dr):ifd<0ord>63then1090
960 f1=peek(bd(d)):f2=0:dj=d
970 d=d+d(p1,dr):ifd<0ord>63then990
980 f2=peek(bd(d))
990 iff1<>160then1040
1000 m0=2:d=dj:iff2<>ch(p2)thenm0=3
1010 iff2=ch(p1)thenm0=4
1020 if(d<8ord>55)andkd=0thenm0=5
1030 goto1070
1040 iff1<>ch(p2)orf2<>160then1090
1050 m0=6:ifpeek(bd(dj)+1)=166thenm0=7
1060 if(d<8ord>55)andkd=0thenm0=8
1070 m0=m0+rnd(1)
1080 ifm0>m1thenm1=m0:l=bd(d):lf=bd(zz):lj=bd(dj):r=int(d/8):qd=d
1090 next:return
1100 rem---screen
1110 pokev+21,0:printchr$(147):poketc,1
1120 printtab(15)" checkers ":zz=96
1130 fora=0to63:forz=0to2
1140 pokebd(a)+z,zz:pokebd(a)+40+z,zz
1150 next
1160 if(aand7)<7thenzz=160+(zz=160)*64
1170 next
1180 poketc,0:a$="#"
1190 fora=1to3:gosub1520:next
1200 poketc,1:a$="+"
1210 fora=6to8:gosub1520:next
1220 rem---get players
1230 q$="players [0,1 or 2] ":se$="012":gosub1350
1240 pl(0)=0:pl(1)=0:a=val(a$)
1250 ifathenpl(1)=1:pl(0)=a-1
1260 cy=22:cx=9:gosub1490:print"press f1 [146] to end game"
1270 tl(0)=12:tl(1)=12
1280 rem---print totals
1290 cy=12:cx=3:a=1:gosub1310
1300 cx=35:a=0
1310 gosub1490:poketc,a
1320 printright$(str$(tl(a)),2)
1330 return
1340 rem---get key
1350 cy=22:gosub1460
1360 cx=(40-len(q$))/2:gosub1490
1370 poketc,1:printq$;
1380 poke198,0:poke204,0
1390 wait198,15:geta$:z=len(se$)
1400 ifa$=mid$(se$,z,1)then1430
1410 z=z-1:ifzthen1400
1420 goto1390
1430 poke204,1:printa$
1440 fora=1to500:next
1450 rem---clear line
1460 poke214,cy-1:print:printsp$
1470 return
1480 rem---plot
1490 poke214,cy-1:print:printtab(cx);
1500 return
1510 rem---print checkers
1520 cy=2+a*2:cx=8+(aand1)*3:gosub1490
1530 forz=0to3
1540 printchr$(18);a$;"$%[157][157][157]*)([145]";
1550 next
1560 return
1570 rem---initialize
1580 printchr$(8)chr$(147)
1590 poke56334,peek(56334)and254
1600 poke1,peek(1)and251
1610 fora=0to511:poke14336+a,peek(53248+a):next
1620 poke1,peek(1)or4
1630 poke56334,peek(56334)or1
1640 poke53272,(peek(53272)and240)or14
1650 fora=0to31:readz:poke14616+a,z:poke14616+63-a,z:next
1660 fora=0to7:poke14616+64+a,peek(14616+a):next
1670 poke53280,7:poke53281,15
1680 poke53282,10:poke53283,2
1690 poke53265,peek(53265)or64
1700 rem---sprite cursors
1710 fora=832to959:pokea,0:next
1720 fora=835to874step3:pokea,192:pokea+2,3:next
1730 fora=0to2:poke832+a,255:poke877+a,255:next
1740 fora=896to943:pokea,255:next
1750 return
1760 rem---character data
1770 data0,0,0,3,7,15,15,31
1780 data0,0,255,255,255,255,255,255
1790 data0,0,0,192,224,240,240,248
1800 data0,0,255,255,255,153,147,135